{extend name="base"/}
{block name="head"}{/block}
<!--{block name="menu"}菜单{/block}-->
{block name="left"}{/block}<!--左边分栏-->
{block name="main"}
<article class="page-container">
    <form class="form form-horizontal" id="form-admin-add" action="<{:url('cate_add')}>" method="post">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>分类名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="<{$find['cateName']?$find['cateName']:''}>" placeholder="" id="cateName" name="cateName">
                <input type="text" class="input-text" value="<{$find['id']?$find['id']:''}>" placeholder="" id="cate_id" name="id" style="display:none;">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>权重：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="number" class="input-text" value="<{$find['weigh']?$find['weigh']:0}>" placeholder="" id="weigh" name="weigh">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">父级分类：</label>
            <div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
                <select class="select" name="parentId" value="<{$find['parentId']?$find['parentId']:''}>" size="1">
                    <option value="0">作为一级</option>
                   <!-- <option value="1">总编</option>
                    <option value="2">栏目主辑</option>
                    <option value="3">栏目编辑</option>-->
                    <{volist name="cateList" id="cate"}>
                    <option value="<{$cate.id}>"><{$cate.cateName}></option>
                    <{/volist}>
                </select>
                </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">备注：</label>
            <div class="formControls col-xs-8 col-sm-9">
                    <textarea name="remark" cols="" rows="" class="textarea" placeholder="说点什么...100个字符以内" dragonfly="true"
                              onKeyUp="$.Huitextarealength(this,100)"><{$find['remark']?$find['remark']:''}></textarea>
                <p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>
{/block}
{block name="footer"}
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__ADMIN__/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__ADMIN__/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__ADMIN__/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
    $(function () {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form-admin-add").validate({
            rules: {
                cateName:{
                    required:true,
                    minlength:1,
                    maxlength:16
                },
            },
            onkeyup: false,
            focusCleanup: true,
            success: "valid",
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    type: 'post',
                    url: "<{:url('cate_add')}>",
                    success: function (data) {
                        layer.msg('添加成功!', {icon: 1, time: 1000});
                        setTimeout(function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            window.parent.location.reload();
                            parent.layer.close(index);
                        },1000);
                    },
                    error: function (XmlHttpRequest, textStatus, errorThrown) {
                        layer.msg('error!', {icon: 1, time: 1000});
                    }
                });
                return false;
            }
        });
    });
  /*  function thisSubmit() {
        $.ajax({
            type:'post',
            url:'<{:url(\'cate_add\')}>',
            data:$("#form-admin-add").serialize(),
            success:function () {
                layer.msg('添加成功!', {icon: 1, time: 1000});
                var index = parent.layer.getFrameIndex(window.name);
                parent.$('.btn-refresh').click();
                parent.layer.close(index);
            },
            error:function () {
                layer.msg('error!', {icon: 1, time: 1000});
            }
        });
    }*/
</script>
{/block}
